/*
 * @FileName: fault.h
 * @Author: GreyQiu qiushaogui@aikosolar.com
 * @Date: 2023-07-18 10:14:33
 * @LastEditors: GreyQiu qiushaogui@aikosolar.com
 * @LastEditTime: 2023-08-09 15:25:43
 * @Description: 
 * 
 * Copyright (c) 2023, All Rights Reserved. 
 */

#ifndef __FAULT_H__
#define __FAULT_H__

#include <stdint.h>
#include <stdbool.h>

#define HIGH  (1)
#define LOW   (0)

/**
 * @description: 故障单元结构
 */
typedef struct {
    uint8_t id;
    uint8_t polarity;       // 比较极性
    uint8_t flag;           // 故障触发标志
    uint8_t auto_clear;     // 自动清除标志
    uint32_t trig_time;     // 故障触发迟滞时间
    uint32_t recovery_time; // 故障恢复迟滞时间
    uint32_t time;
    float * singal_addr; // 信号地址
    float threshold;     // 信号故障阈值
    void (*handler)(uint32_t fault_id, uint16_t flag); // 故障触发时的回调处理
} fault_t;

void fault_check(fault_t * obj);

#endif // __FAULT_H__
